package com.molin.ArrayList;

import com.molin.ArrayList.domain.Student;

import java.util.ArrayList;

public class StuDemoArrayList {
    public static void main(String[] args) {
        Student st1=new Student("zhangsan1",10);
        Student st2=new Student("zhangsan2",10);
        Student st3=new Student("zhangsan3",20);
        ArrayList<Student> stuArr=new ArrayList<>();
        stuArr.add(st1);
        stuArr.add(st2);
        stuArr.add(st3);
        ArrayList<Student> stuResult=getList(stuArr);
    }
    public static ArrayList<Student> getList(ArrayList<Student> stuArr){
        ArrayList<Student> newArr=new ArrayList<>();
        for (int i = 0; i < stuArr.size(); i++) {
            Student st = stuArr.get(i);
            if(st.getAge()<18){
                newArr.add(st);
            }
        }
        return newArr;
    }
}
